export function timeFix() {
    const time = new Date();
    const hour = time.getHours();
    return hour < 9
        ? "早上好"
        : hour <= 11
            ? "上午好"
            : hour <= 13
                ? "中午好"
                : hour < 20
                    ? "下午好"
                    : "晚上好";
}

export function welcome() {
    const arr = [
        "休息一会儿吧",
        "准备吃什么呢?",
        "要不要打一把 DOTA",
        "我猜你可能累了",
    ];
    let index = Math.floor(Math.random() * arr.length);
    return arr[index];
}

/**
 * 获取yyyy-mm-dd HH:mm:ss
 */
export function getNowDate(timestamp) {
    let date = new Date();
    if (timestamp) {
        date = new Date(timestamp);
    }
    let sign2 = ":";
    let year = date.getFullYear(); // 年
    let month = date.getMonth() + 1; // 月
    let day = date.getDate(); // 日
    let hour = date.getHours(); // 时
    let minutes = date.getMinutes(); // 分
    let seconds = date.getSeconds(); //秒
    let weekArr = [
        "星期一",
        "星期二",
        "星期三",
        "星期四",
        "星期五",
        "星期六",
        "星期天",
    ];
    let week = weekArr[date.getDay()];
    // 给一位数的数据前面加 “0”
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (day >= 0 && day <= 9) {
        day = "0" + day;
    }
    if (hour >= 0 && hour <= 9) {
        hour = "0" + hour;
    }
    if (minutes >= 0 && minutes <= 9) {
        minutes = "0" + minutes;
    }
    if (seconds >= 0 && seconds <= 9) {
        seconds = "0" + seconds;
    }
    return (
        year +
        "-" +
        month +
        "-" +
        day +
        " " +
        hour +
        sign2 +
        minutes +
        sign2 +
        seconds
    );
}


